# -*- coding:utf-8 -*-
from __future__ import unicode_literals

from django.contrib import admin
from wenlincms.conf.models import Setting

from .models import ELRegion, ELNic, ELSeic, ELRegisterTypeTax, ELCA02, ELCA04, ELCA11, ELCA12, ELCA16, ELCA25, ELCA73, ELCA75, ELCA76, ELCE02, \
    ELCE10, ELCC01, ELHGGoodsCode

admin.site.unregister(Setting)


class ELCodeAdmin(admin.ModelAdmin):
    list_display = ["id", "code", "name", ]
    search_fields = ["name", ]
    raw_id_fields = ("parent",)
    ordering = ("code",)


class ELRegionAdmin(admin.ModelAdmin):
    list_display = ["id", "code", "level", "name", "get_parent", "fulltitle", ]
    list_filter = ["level"]
    search_fields = ["name", ]
    raw_id_fields = ("parent",)
    ordering = ("code",)

    def get_parent(self, obj):
        if obj.parent:
            return obj.parent.name
        return ""

    get_parent.short_description = '上级'
    get_parent.admin_order_field = 'parent__name'


class ELCA16Admin(admin.ModelAdmin):
    list_display = ["id", "code", "name", "get_parent", "level", ]
    search_fields = ["name", ]
    raw_id_fields = ("parent",)
    ordering = ("code",)

    def get_parent(self, obj):
        if obj.parent:
            return obj.parent.name
        return ""

    get_parent.short_description = '上级分类'
    get_parent.admin_order_field = 'parent__name'


# admin.site.register(ELRegion, ELRegionAdmin)
# admin.site.register(ELNic, ELRegionAdmin)
# admin.site.register(ELSeic, ELRegionAdmin)
# admin.site.register(ELRegisterTypeTax, ELCodeAdmin)
# admin.site.register(ELCA02, ELCodeAdmin)
# admin.site.register(ELCA04, ELCodeAdmin)
# admin.site.register(ELCA11, ELCodeAdmin)
# admin.site.register(ELCA12, ELCodeAdmin)
# admin.site.register(ELCA16, ELCA16Admin)
# admin.site.register(ELCA25, ELCodeAdmin)
# admin.site.register(ELCA73, ELCodeAdmin)
# admin.site.register(ELCA75, ELCodeAdmin)
# admin.site.register(ELCA76, ELCodeAdmin)
# admin.site.register(ELCE02, ELCodeAdmin)
# admin.site.register(ELCE10, ELCodeAdmin)
# admin.site.register(ELCC01, ELCodeAdmin)
# admin.site.register(ELHGGoodsCode, ELRegionAdmin)
